﻿// -------------------------------------------------------------------------------------------------------------------------------
// <copyright file="TestConstructorWithLengthParameter.cs" company="Exul">
//     Copyright (c) Exul. All rights reserved.
// </copyright>
// <author>
//     Exul
// </author>
// -------------------------------------------------------------------------------------------------------------------------------

namespace ExulLibrary.Mathematics.LinearAlgebra.Tests.DenseVectorTest
{
    #region Usings

    using ExulLibrary.Exceptions;

    using NUnit.Framework;

    #endregion

    /// <summary>
    ///     Test suite for the constructor of <see cref="DenseVector{T}"/> with length parameter.
    /// </summary>
    [TestFixture]
    [Category("ExulLibrary.Mathematics.LinearAlgebra.DenseVector{T}")]
    public sealed class TestConstructorWithLengthParameter
    {
        /// <summary>
        ///     Tests the constructor when length parameter is equal to a positive value.
        /// </summary>
        /// <param name="length">
        ///     The length of vector.
        /// </param>
        [Test]
        public void WhenLengthIsPositive([Values(1, 2)] int length)
        {
            // Act
            var vector = new DenseVector<object>(length);

            // Assert
            Assert.That(vector.Length, Is.EqualTo(length));
            Assert.That(vector.Values, Is.Not.Null & Has.Length.EqualTo(length));
        }

        #if SAFE

        /// <summary>
        ///     Tests the constructor when length parameter is equal to zero or a negative value.
        /// </summary>
        /// <param name="length">
        ///     The length of vector.
        /// </param>
        [Test]
        public void WhenLengthIsNegativeOrZero([Values(0, -1)] int length)
        {
            // Act and Assert
            Assert.That(
                () => new DenseVector<object>(length),
                Throws.TypeOf<NegativeOrZeroSizeException>().With.Property("ParamName").EqualTo("length"));
        }

        #endif
    }
}